package behavioral_pattern.mediator_pattern;

import behavioral_pattern.mediator_pattern.colleague.IDepartment;
import behavioral_pattern.mediator_pattern.concrete_colleague.PurchaseDepartment;
import behavioral_pattern.mediator_pattern.concrete_colleague.SaleDepartment;
import behavioral_pattern.mediator_pattern.concrete_colleague.StockDepartment;
import behavioral_pattern.mediator_pattern.concrete_mediator.ConcreteMediator;

public class Test {
    public static void main(String[] args) {
        // 中介者
        ConcreteMediator mediator = new ConcreteMediator();
        // 销售部门
        IDepartment sale = new SaleDepartment(mediator);
        // 库存部门
        IDepartment stock = new StockDepartment(mediator);


        // 采购部门
        IDepartment purchase = new PurchaseDepartment(mediator);

        mediator.setSale(sale);
        mediator.setPurchase(purchase);
        mediator.setStock(stock);

        // 销售商品剩余数量
        sale.setProductNum(30);
        System.out.println("商品库存:" + sale.productNum);
        System.out.println("======售出5件======");
        sale.work(5);

        System.out.println("======售出10件======");
        sale.work(10);
        //stock.communicat();
    }
}
